import { reqGetGoodsInfoData } from "@/api"


const state = {
    goodsInfo:{}
}

const getters = {
    goodsList(state) {
        return state.goodsInfo.goodsList
    },

    attrsList(state) {
        return state.goodsInfo.attrsList
    },

    trademarkList(state) {
        return state.goodsInfo.trademarkList
    },

    total(state) {
        return state.goodsInfo.total
    }
}

const actions = {
    async getGoodsParamsInfoData({commit},searchParams) {
        const result = await reqGetGoodsInfoData(searchParams)
        if(result.code === 200) {
            commit('SAVE_GOODS_INFO_DATA', result.data)
        }else{
            console.log(result.message)
        }
    }
}

const mutations = {
    SAVE_GOODS_INFO_DATA(state, searchParams) {
        state.goodsInfo = searchParams
    }
}


export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations,
}